export class licenseList{constructor(e="full"){let t={by:{name:"Attribution",link:"https://creativecommons.org/licenses/by/4.0/",image:"https://i.creativecommons.org/l/by/4.0/88x31.png"},"by-sa":{name:"Attribution Share a like",link:"https://creativecommons.org/licenses/by-sa/4.0/",image:"https://i.creativecommons.org/l/by-sa/4.0/88x31.png"},"by-nd":{name:"Attribution No derivatives",link:"https://creativecommons.org/licenses/by-nd/4.0/",image:"https://i.creativecommons.org/l/by-nd/4.0/88x31.png"},"by-nc":{name:"Attribution non-commercial",link:"https://creativecommons.org/licenses/by-nc/4.0/",image:"https://i.creativecommons.org/l/by-nc/4.0/88x31.png"},"by-nc-sa":{name:"Attribution non-commercial share a like",link:"https://creativecommons.org/licenses/by-nc-sa/4.0/",image:"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"},"by-nc-nd":{name:"Attribution Non-commercial No derivatives",link:"https://creativecommons.org/licenses/by-nc-nd/4.0/",image:"https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"}};if("select"==e){var i={};for(var n in t)i[n]=t[n].name;return i}return t}}import{LitElement as e,html as t,css as i}from"../../lit/index.js";import{SchemaBehaviors as n}from"../schema-behaviors/schema-behaviors.js";import{DDDSuper as s}from"../d-d-d/d-d-d.js";class LicenseElement extends(n(s(e))){static get styles(){return[i`
        :host {
          display: block;
          line-height: var(--ddd-line-height-140);
          background-color: var(--license-background-color);
        }
        :host:after {
          content: "License";
          position: relative;
          float: right;
          bottom: var(--ddd-spacing-9);
          right: var(--ddd-spacing-2);
          font-size: var(--ddd-font-size-ms);
          color: var(--ddd-theme-default-slateGray);
          font-style: italic;
        }
        .license-body {
          padding: var(--ddd-spacing-8);
          background-color: var(--ddd-theme-default-limestoneMaxLight);
          color: var(--ddd-theme-default-slateGray);
        }

        :host([display-method="footnote"]) {
          visibility: hidden;
          opacity: 0;
        }
        :host([display-method="popup"]) {
          display: block;
        }
        .license-link {
          font-style: italic;
        }
        a,
        a:any-link,
        a:-webkit-any-link {
          color: var(--ddd-theme-default-link);
          font-weight: var(--ddd-font-weight-bold);
        }
        .big-license-link img {
          margin-right: 0 var(--ddd-spacing-2) var(--ddd-spacing-2) 0;
          width: var(--ddd-icon-3xl);
          height: var(--ddd-icon-xs);
          vertical-align: middle;
        }
        .work-title {
          font-weight: bold;
        }
      `]}render(){return t`
      <meta
        rel="cc:license"
        href="${this.licenseLink}"
        content="License: ${this.licenseName}"
      />
      <div
        class="license-body"
        xmlns:cc="${this.licenseLink}"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
      >
        ${this.licenseImage?t`
              <a
                class="big-license-link"
                target="_blank"
                href="${this.licenseLink}"
                rel="noopener noreferrer"
                ><img
                  loading="lazy"
                  alt="${this.licenseName} graphic"
                  src="${this.licenseImage}"
              /></a>
            `:""}
        <a
          class="work-title license-link"
          rel="dc:type"
          href="${this.source}"
          property="dc:title"
          >${this.title}</a
        >
        by
        <span rel="cc:attributionURL" property="cc:attributionName"
          >${this.creator}</span
        >
        ${this.license?t`is licensed under a
              <a class="license-link" target="_blank" href="${this.licenseLink}"
                >${this.licenseName}</a
              >.`:""} <span rel="dc:source" href="${this.source}"></span>
        ${this.hasMore?t`
              <span
                >Permissions beyond the scope of this license are available
                <a
                  rel="cc:morePermissions"
                  target="_blank"
                  href="${this.moreLink}"
                  rel="noopener noreferrer"
                  >${this.moreLabel}</a
                >.</span
              >
            `:""}
      </div>
    `}static get tag(){return"license-element"}static get properties(){return{...super.properties,title:{type:String},creator:{type:String},source:{type:String},licenseName:{type:String,attribute:"license-name"},licenseImage:{type:String,attribute:"license-image"},licenseLink:{type:String,attribute:"license-link"},license:{type:String},moreLabel:{type:String,attribute:"more-label"},moreLink:{type:String,attribute:"more-link"},hasMore:{type:Boolean,attribute:"has-more"}}}constructor(){super(),this.licenseList=new licenseList,this.creator="(author)",this.source=null,this.moreLabel="on the licensing details page"}updated(e){e.forEach(((e,t)=>{"license"==t&&this._licenseUpdated(this[t]),"moreLink"==t&&(this.hasMode=this._computeHasMore(this.moreLink))}))}static get haxProperties(){return{canScale:!1,canEditSource:!0,gizmo:{title:"License",description:"Provide a license for you rwork",icon:"icons:copyright",color:"grey",tags:["Authoring","content","copyright","license","cc0","cc-by","cc-by-sa","cc-by-nd","cc-by-nc","cc-by-nc-sa","cc-by-nc-nd","citation"],handles:[{type:"license",source:"source",title:"title",author:"creator",license:"license"}],meta:{author:"HAXTheWeb core team"}},settings:{configure:[{property:"title",title:"Title",description:"The title of the work being cited.",inputMethod:"textfield",icon:"editor:title"},{property:"source",title:"Source link",description:"The source url for the element this is citing.",inputMethod:"textfield",icon:"link",validationType:"url"},{property:"license",title:"License",description:"The source url for the element this is citing.",inputMethod:"select",options:new licenseList("select"),icon:"link"},{property:"creator",title:"Creator",description:"Who made or owns this.",inputMethod:"textfield",icon:"link"}],advanced:[{property:"moreLink",title:"Source link",description:"Link to additional licensing details",inputMethod:"textfield",validationType:"url"},{property:"moreLabel",title:"more label",description:"Label for more licensing details",inputMethod:"textfield"}]},demoSchema:[{tag:"license-element",properties:{title:"Wonderland",creator:"Mad Hatter",source:"https://haxtheweb.org/",license:"by"},content:""}]}}_computeHasMore(e){return void 0!==e&&""!==e}_licenseUpdated(e){void 0!==e&&void 0!==this.licenseList[e]&&(this.licenseName=this.licenseList[e].name,this.licenseLink=this.licenseList[e].link,this.licenseImage=this.licenseList[e].image)}}customElements.define(LicenseElement.tag,LicenseElement);export{LicenseElement};