@ddict/popup 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/popup.es.js CHANGED
@@ -108,7 +108,7 @@ const _hoisted_4$8 = /* @__PURE__ */ createElementVNode("path", {
108
108
  const _hoisted_5$7 = [
109
109
  _hoisted_4$8
110
110
  ];
111
- const _hoisted_6$6 = {
111
+ const _hoisted_6$5 = {
112
112
  key: 1,
113
113
  xmlns: "http://www.w3.org/2000/svg",
114
114
  class: "h-6 w-6",
@@ -151,7 +151,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
151
151
  onClick: _cache[2] || (_cache[2] = (...args) => $options.swap && $options.swap(...args))
152
152
  }, [
153
153
  $data.src != "auto" ? (openBlock(), createElementBlock("svg", _hoisted_3$8, _hoisted_5$7)) : createCommentVNode("", true),
154
- $data.src == "auto" ? (openBlock(), createElementBlock("svg", _hoisted_6$6, _hoisted_8$2)) : createCommentVNode("", true)
154
+ $data.src == "auto" ? (openBlock(), createElementBlock("svg", _hoisted_6$5, _hoisted_8$2)) : createCommentVNode("", true)
155
155
  ]),
156
156
  withDirectives(createElementVNode("select", {
157
157
  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $data.target = $event),
@@ -383,7 +383,7 @@ const _hoisted_5$6 = /* @__PURE__ */ createElementVNode("svg", {
383
383
  d: "M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"
384
384
  })
385
385
  ], -1);
386
- const _hoisted_6$5 = [
386
+ const _hoisted_6$4 = [
387
387
  _hoisted_5$6
388
388
  ];
389
389
  const _hoisted_7$4 = {
@@ -408,14 +408,8 @@ const _hoisted_9$1 = /* @__PURE__ */ createElementVNode("svg", {
408
408
  const _hoisted_10$1 = [
409
409
  _hoisted_9$1
410
410
  ];
411
- const _hoisted_11$1 = /* @__PURE__ */ createElementVNode("label", {
412
- for: "auto_translate",
413
- class: "text-xs ml-1"
414
- }, " Auto translate ", -1);
415
- const _hoisted_12$1 = {
416
- key: 0,
417
- class: "float-right text-xs"
418
- };
411
+ const _hoisted_11$1 = { class: "cursor-pointer label justify-start" };
412
+ const _hoisted_12$1 = /* @__PURE__ */ createElementVNode("span", { class: "ml-1 label-text text-xs" }, "Auto translate", -1);
419
413
  function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
420
414
  return openBlock(), createElementBlock("div", null, [
421
415
  createElementVNode("div", _hoisted_1$7, [
@@ -429,12 +423,12 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
429
423
  key: 1,
430
424
  class: "pointer",
431
425
  onClick: _cache[1] || (_cache[1] = (...args) => $options.stop && $options.stop(...args))
432
- }, _hoisted_6$5)) : createCommentVNode("", true),
426
+ }, _hoisted_6$4)) : createCommentVNode("", true),
433
427
  $props.data.ddictSrc ? (openBlock(), createElementBlock("span", _hoisted_7$4, toDisplayString($props.data.ddictSrc), 1)) : createCommentVNode("", true),
434
428
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.sentences, (sentence, index) => {
435
429
  return openBlock(), createElementBlock("span", {
436
430
  key: `${sentence.src_translit}-${index}`,
437
- class: "text-muted small"
431
+ class: "italic"
438
432
  }, [
439
433
  sentence.src_translit ? (openBlock(), createElementBlock("span", _hoisted_8$1, " \u2015 " + toDisplayString(sentence.src_translit), 1)) : createCommentVNode("", true)
440
434
  ]);
@@ -461,17 +455,15 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
461
455
  ]
462
456
  ])
463
457
  ]),
464
- createElementVNode("p", null, [
458
+ createElementVNode("label", _hoisted_11$1, [
465
459
  withDirectives(createElementVNode("input", {
466
460
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.auto_translate = $event),
467
- id: "auto_translate",
468
461
  type: "checkbox",
469
462
  class: "toggle toggle-xs"
470
463
  }, null, 512), [
471
464
  [vModelCheckbox, $data.auto_translate]
472
465
  ]),
473
- _hoisted_11$1,
474
- $data.input != "" ? (openBlock(), createElementBlock("span", _hoisted_12$1, toDisplayString($data.input.length) + " / " + toDisplayString($data.INPUT_MAX_LENGTH), 1)) : createCommentVNode("", true)
466
+ _hoisted_12$1
475
467
  ])
476
468
  ]);
477
469
  }
@@ -598,7 +590,7 @@ const _hoisted_5$5 = /* @__PURE__ */ createElementVNode("svg", {
598
590
  d: "M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"
599
591
  })
600
592
  ], -1);
601
- const _hoisted_6$4 = [
593
+ const _hoisted_6$3 = [
602
594
  _hoisted_5$5
603
595
  ];
604
596
  const _hoisted_7$3 = {
@@ -635,8 +627,11 @@ const _hoisted_14 = [
635
627
  _hoisted_12,
636
628
  _hoisted_13
637
629
  ];
638
- const _hoisted_15 = { key: 0 };
639
- const _hoisted_16 = /* @__PURE__ */ createElementVNode("span", { class: "float-right text-xs" }, "Powered by Google Translate", -1);
630
+ const _hoisted_15 = {
631
+ key: 0,
632
+ class: "label justify-end"
633
+ };
634
+ const _hoisted_16 = /* @__PURE__ */ createElementVNode("span", { class: "text-xs" }, "Powered by Google Translate.", -1);
640
635
  const _hoisted_17 = [
641
636
  _hoisted_16
642
637
  ];
@@ -653,7 +648,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
653
648
  key: 1,
654
649
  class: "pointer",
655
650
  onClick: _cache[1] || (_cache[1] = (...args) => $options.stop && $options.stop(...args))
656
- }, _hoisted_6$4)) : createCommentVNode("", true),
651
+ }, _hoisted_6$3)) : createCommentVNode("", true),
657
652
  $props.data.ddictTarget ? (openBlock(), createElementBlock("span", _hoisted_7$3, toDisplayString($props.data.ddictTarget), 1)) : createCommentVNode("", true)
658
653
  ])) : createCommentVNode("", true),
659
654
  $props.data != "" ? (openBlock(), createElementBlock("div", {
@@ -694,7 +689,7 @@ const _hoisted_2$5 = { class: "card-body" };
694
689
  const _hoisted_3$5 = { class: "card-title font-bold" };
695
690
  const _hoisted_4$5 = { class: "list-group list-group-flush" };
696
691
  const _hoisted_5$4 = { class: "capitalize font-bold" };
697
- const _hoisted_6$3 = /* @__PURE__ */ createElementVNode("br", null, null, -1);
692
+ const _hoisted_6$2 = /* @__PURE__ */ createElementVNode("br", null, null, -1);
698
693
  const _hoisted_7$2 = { class: "italic" };
699
694
  function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
700
695
  return $props.data.definitions ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
@@ -712,7 +707,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
712
707
  key: `${entry.definition_id}-${index2}`
713
708
  }, [
714
709
  createElementVNode("span", null, toDisplayString(entry.gloss), 1),
715
- _hoisted_6$3,
710
+ _hoisted_6$2,
716
711
  createElementVNode("small", _hoisted_7$2, toDisplayString(entry.example), 1)
717
712
  ]);
718
713
  }), 128))
@@ -746,7 +741,7 @@ const _hoisted_2$4 = { class: "card-body" };
746
741
  const _hoisted_3$4 = { class: "card-title" };
747
742
  const _hoisted_4$4 = { class: "list-group list-group-flush" };
748
743
  const _hoisted_5$3 = { class: "capitalize font-bold" };
749
- const _hoisted_6$2 = ["onClick"];
744
+ const _hoisted_6$1 = ["onClick"];
750
745
  const _hoisted_7$1 = { class: "italic" };
751
746
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
752
747
  return $props.data.dict ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
@@ -756,7 +751,7 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
756
751
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.dict, (dict, index) => {
757
752
  return openBlock(), createElementBlock("li", {
758
753
  key: `${dict.pos}-${index}`,
759
- class: "list-group-item"
754
+ class: "list-group-item mb-2"
760
755
  }, [
761
756
  createElementVNode("h5", _hoisted_5$3, toDisplayString(dict.pos), 1),
762
757
  (openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
@@ -766,7 +761,7 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
766
761
  createElementVNode("span", {
767
762
  class: "badge bg-neutral",
768
763
  onClick: ($event) => $options.translate(entry.word)
769
- }, toDisplayString(entry.word), 9, _hoisted_6$2),
764
+ }, toDisplayString(entry.word), 9, _hoisted_6$1),
770
765
  createElementVNode("small", _hoisted_7$1, " \u2015 " + toDisplayString(entry.reverse_translation.join(", ")), 1)
771
766
  ]);
772
767
  }), 128))
@@ -830,7 +825,7 @@ const _hoisted_2$2 = { class: "card-body" };
830
825
  const _hoisted_3$2 = { class: "card-title font-bold" };
831
826
  const _hoisted_4$2 = { class: "list-group list-group-flush" };
832
827
  const _hoisted_5$1 = { class: "capitalize font-bold" };
833
- const _hoisted_6$1 = ["onClick"];
828
+ const _hoisted_6 = ["onClick"];
834
829
  const _hoisted_7 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
835
830
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
836
831
  return $props.data.synsets ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
@@ -840,7 +835,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
840
835
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.synsets, (dict, index) => {
841
836
  return openBlock(), createElementBlock("li", {
842
837
  key: `${dict.pos}-${index}`,
843
- class: "list-group-item"
838
+ class: "list-group-item mb-2"
844
839
  }, [
845
840
  createElementVNode("h5", _hoisted_5$1, toDisplayString(dict.pos), 1),
846
841
  (openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
@@ -854,7 +849,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
854
849
  createElementVNode("span", {
855
850
  class: "badge bg-neutral ml-1",
856
851
  onClick: ($event) => _ctx.$emit("translate", synonym)
857
- }, toDisplayString(synonym), 9, _hoisted_6$1),
852
+ }, toDisplayString(synonym), 9, _hoisted_6),
858
853
  _hoisted_7
859
854
  ]);
860
855
  }), 128))
@@ -883,34 +878,31 @@ const _sfc_main$1 = {
883
878
  const _hoisted_1$1 = { key: 0 };
884
879
  const _hoisted_2$1 = { class: "card-body" };
885
880
  const _hoisted_3$1 = { class: "card-title font-bold" };
886
- const _hoisted_4$1 = { class: "card-body" };
887
- const _hoisted_5 = ["onClick"];
888
- const _hoisted_6 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
881
+ const _hoisted_4$1 = ["onClick"];
882
+ const _hoisted_5 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
889
883
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
890
884
  return $props.data.related_words && $props.data.related_words.word ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
891
885
  createElementVNode("div", _hoisted_2$1, [
892
886
  createElementVNode("h2", _hoisted_3$1, toDisplayString($data.name), 1),
893
- createElementVNode("div", _hoisted_4$1, [
894
- (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.related_words.word, (word, index) => {
895
- return openBlock(), createElementBlock("span", {
896
- key: `${word}-${index}`
897
- }, [
898
- createElementVNode("span", {
899
- class: "badge bg-neutral",
900
- onClick: ($event) => _ctx.$emit("translate", word)
901
- }, toDisplayString(word), 9, _hoisted_5),
902
- _hoisted_6
903
- ]);
904
- }), 128))
905
- ])
887
+ (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.related_words.word, (word, index) => {
888
+ return openBlock(), createElementBlock("span", {
889
+ key: `${word}-${index}`
890
+ }, [
891
+ createElementVNode("span", {
892
+ class: "badge bg-neutral",
893
+ onClick: ($event) => _ctx.$emit("translate", word)
894
+ }, toDisplayString(word), 9, _hoisted_4$1),
895
+ _hoisted_5
896
+ ]);
897
+ }), 128))
906
898
  ])
907
899
  ])) : createCommentVNode("", true);
908
900
  }
909
901
  var More = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
910
902
  const _hoisted_1 = { class: "p-1" };
911
- const _hoisted_2 = { class: "mt-3 grid grid-cols-1 md:grid-cols-2" };
912
- const _hoisted_3 = { class: "w-full pr-1" };
913
- const _hoisted_4 = { class: "w-full pl-1" };
903
+ const _hoisted_2 = { class: "mt-3 grid grid-cols-1 md:grid-cols-2 gap-3" };
904
+ const _hoisted_3 = { class: "w-full" };
905
+ const _hoisted_4 = { class: "w-full" };
914
906
  const __default__ = {
915
907
  name: "Popup",
916
908
  props: {
package/dist/popup.umd.js CHANGED
@@ -1 +1 @@
1
- (function(d,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(d=typeof globalThis!="undefined"?globalThis:d||self,t(d.Popup={},d.Vue))})(this,function(d,t){"use strict";var y={isRTL:N};function N(e){return["ar","fa","iw","yi","ur","pa"].indexOf(e)>-1}var h=(e,s)=>{const l=e.__vccOpts||e;for(const[i,r]of s)l[i]=r;return l};const u={props:{select:{type:Object,default:null}},emits:["select"],data(){return{src:"",target:"",recents:{src:[],target:[]}}},watch:{select(e){!e||(this.src=e.src,this.target=e.target,this.loadRecents())}},methods:{onRecentSrc(e){this.src=e,this.onSelect()},onRecentTarget(e){this.target=e,this.onSelect()},swap(){if(this.src==="auto"||!this.select.srcs[this.target]||!this.select.targets[this.src])return;const e=this.target;this.target=this.src,this.src=e,this.onSelect()},onSelect(){const e=JSON.parse(JSON.stringify(this.select));e.src=this.src,e.target=this.target,this.$emit("select",e),this.saveRecents(this.src,this.target)},loadRecents(){const e=JSON.parse(localStorage.getItem("recents"));!e||(this.recents=e)},saveRecents(e,s){this.recents.src.includes(e)||this.recents.src.push(e),this.recents.target.includes(s)||this.recents.target.push(s),this.recents.src.length>3&&this.recents.src.shift(),this.recents.target.length>3&&this.recents.target.shift(),localStorage.setItem("recents",JSON.stringify(this.recents))}}},w={key:0,class:"flex flex-row"},V=["value"],$={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},S=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"},null,-1)],x={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},C=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 7l5 5m0 0l-5 5m5-5H6"},null,-1)],b=["value"],T={key:1},L=["onClick"],D=["onClick"];function M(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock(t.Fragment,null,[l.select?(t.openBlock(),t.createElementBlock("div",w,[t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[0]||(s[0]=n=>r.src=n),class:"select select-bordered grow",onChange:s[1]||(s[1]=(...n)=>o.onSelect&&o.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.srcs,(n,a)=>(t.openBlock(),t.createElementBlock("option",{value:a,key:a},t.toDisplayString(n),9,V))),128))],544),[[t.vModelSelect,r.src]]),t.createElementVNode("button",{class:"grow-0 ml-2 mr-2",onClick:s[2]||(s[2]=(...n)=>o.swap&&o.swap(...n))},[r.src!="auto"?(t.openBlock(),t.createElementBlock("svg",$,S)):t.createCommentVNode("",!0),r.src=="auto"?(t.openBlock(),t.createElementBlock("svg",x,C)):t.createCommentVNode("",!0)]),t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[3]||(s[3]=n=>r.target=n),class:"select select-bordered grow",onChange:s[4]||(s[4]=(...n)=>o.onSelect&&o.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.targets,(n,a)=>(t.openBlock(),t.createElementBlock("option",{value:a,key:a},t.toDisplayString(n),9,b))),128))],544),[[t.vModelSelect,r.target]])])):t.createCommentVNode("",!0),l.select&&r.src&&r.target&&r.recents?(t.openBlock(),t.createElementBlock("p",T,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.src,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:a=>o.onRecentSrc(n),class:"badge badge-sm ml-1 badge-outline"},t.toDisplayString(l.select.srcs[n]),9,L))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.target,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:a=>o.onRecentTarget(n),class:"badge badge-sm ml-1 float-right mt-1"},t.toDisplayString(l.select.targets[n]),9,D))),128))])):t.createCommentVNode("",!0)],64)}var j=h(u,[["render",M]]),k={INPUT_MAX_LENGTH:5e3,INPUT_DELAY:1e3},m={init:H,autoResize:O};const g=100,E=600,I=10;function H(e,s){s&&(e.maxlength=s),e.spellcheck=!1,p(e,g)}function O(e){if(e.value==""){p(e,g);return}if(e.scrollHeight<g){p(e,g);return}if(e.scrollHeight>E){p(e,E);return}e.style.height.replace("px","")>e.scrollHeight||p(e,e.scrollHeight+I)}function p(e,s){e.style.height=`${s}px`}const B="auto_translate",z={props:{data:{type:Object,default:null},tts:{type:Object,default:null},replace:{type:String,default:""}},data(){return{input:"",INPUT_MAX_LENGTH:k.INPUT_MAX_LENGTH,input_timeout:null,player:new Audio,playing:!1,ttsIndex:0,auto_translate:!0,firstTime:!0}},computed:{rtl(){return this.data?y.isRTL(this.data.src):!1}},watch:{replace(e){this.input=e,(this.firstTime||!this.auto_translate)&&setTimeout(()=>{this.$refs.input.select()},100),this.firstTime=!1},tts(){this.ttsIndex=0},auto_translate(e){e&&this.translate(),localStorage.setItem(B,e)}},mounted(){m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.src.length){this.stop();return}this.play()}),this.$refs.input.addEventListener("input",()=>{m.autoResize(this.$refs.input),!!this.auto_translate&&(clearTimeout(this.input_timeout),this.input_timeout=setTimeout(this.translate,k.INPUT_DELAY))}),this.$refs.input.addEventListener("keyup",e=>{this.auto_translate||e&&e.keyCode===13&&this.translate()})},created(){localStorage.getItem(B)==="false"&&(this.auto_translate=!1)},methods:{play(){!this.tts.src||(this.player.src=this.tts.src[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},clear(){this.$emit("clear"),this.input="",m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.$refs.input.focus()},translate(){if(!this.input){this.clear();return}this.$emit("translate",this.input)}}},R={class:"relative indicator w-full"},A={key:0,class:"absolute top-0 left-0 w-4/5 ml-2 text-sm truncate"},F=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],P=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],U={key:2,class:"ml-1"},G={key:0},X=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)],J=t.createElementVNode("label",{for:"auto_translate",class:"text-xs ml-1"}," Auto translate ",-1),Y={key:0,class:"float-right text-xs"};function q(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",R,[l.data?(t.openBlock(),t.createElementBlock("div",A,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>o.play&&o.play(...n))},F)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>o.stop&&o.stop(...n))},P)):t.createCommentVNode("",!0),l.data.ddictSrc?(t.openBlock(),t.createElementBlock("span",U,t.toDisplayString(l.data.ddictSrc),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.sentences,(n,a)=>(t.openBlock(),t.createElementBlock("span",{key:`${n.src_translit}-${a}`,class:"text-muted small"},[n.src_translit?(t.openBlock(),t.createElementBlock("span",G," \u2015 "+t.toDisplayString(n.src_translit),1)):t.createCommentVNode("",!0)]))),128))])):t.createCommentVNode("",!0),r.input!=""?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>o.clear&&o.clear(...n)),class:"indicator-item m-3"},X)):t.createCommentVNode("",!0),t.withDirectives(t.createElementVNode("textarea",{id:"input",ref:"input","onUpdate:modelValue":s[3]||(s[3]=n=>r.input=n),class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":o.rtl?"right":"left"}),autofocus:""},null,4),[[t.vModelText,r.input,void 0,{trim:!0}]])]),t.createElementVNode("p",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":s[4]||(s[4]=n=>r.auto_translate=n),id:"auto_translate",type:"checkbox",class:"toggle toggle-xs"},null,512),[[t.vModelCheckbox,r.auto_translate]]),J,r.input!=""?(t.openBlock(),t.createElementBlock("span",Y,t.toDisplayString(r.input.length)+" / "+t.toDisplayString(r.INPUT_MAX_LENGTH),1)):t.createCommentVNode("",!0)])])}var K=h(z,[["render",q]]);const Q={props:{data:{type:Object,default:null},tts:{type:Object,default:null}},data(){return{player:new Audio,playing:!1,copied:!1,ttsIndex:0}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{data(e){if(!e){this.$refs.input.value="",m.init(this.$refs.input);return}this.$refs.input.value=e.sentences.map(s=>s.trans).join(""),m.autoResize(this.$refs.input)},tts(){this.ttsIndex=0}},mounted(){m.init(this.$refs.input),m.autoResize(this.$refs.input),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.target.length){this.stop();return}this.play()})},methods:{play(){!this.tts.target||(this.player.src=this.tts.target[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},copy(){const e=this.$refs.input.value;!e||(navigator.clipboard.writeText(e),this.copied=!0,setTimeout(()=>{this.copied=!1},500))}}},W={class:"relative indicator w-full"},Z={key:0,class:"absolute top-0 left-0 w-2/3 ml-2 text-sm truncate"},v=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],tt=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],et={key:2,class:"ml-1"},st={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},nt=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"},null,-1)],lt={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},rt=[t.createElementVNode("path",{d:"M8 2a1 1 0 000 2h2a1 1 0 100-2H8z"},null,-1),t.createElementVNode("path",{d:"M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z"},null,-1)],ot={key:0},at=[t.createElementVNode("span",{class:"float-right text-xs"},"Powered by Google Translate",-1)];function it(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",W,[l.data?(t.openBlock(),t.createElementBlock("div",Z,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>o.play&&o.play(...n))},v)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>o.stop&&o.stop(...n))},tt)):t.createCommentVNode("",!0),l.data.ddictTarget?(t.openBlock(),t.createElementBlock("span",et,t.toDisplayString(l.data.ddictTarget),1)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),l.data!=""?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>o.copy&&o.copy(...n)),class:"indicator-item m-3"},[r.copied?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("svg",st,nt)),r.copied?(t.openBlock(),t.createElementBlock("svg",lt,rt)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),t.createElementVNode("textarea",{ref:"input",class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":o.rtl?"right":"left"}),readonly:"",spellcheck:"false"},null,4)]),l.data?(t.openBlock(),t.createElementBlock("p",ot,at)):t.createCommentVNode("",!0)])}var ct=h(Q,[["render",it]]);const dt={props:{data:{type:Object,default:null}},data(){return{name:"Definitions"}}},ht={key:0},mt={class:"card-body"},pt={class:"card-title font-bold"},_t={class:"list-group list-group-flush"},kt={class:"capitalize font-bold"},gt=t.createElementVNode("br",null,null,-1),ft={class:"italic"};function yt(e,s,l,i,r,o){return l.data.definitions?(t.openBlock(),t.createElementBlock("div",ht,[t.createElementVNode("div",mt,[t.createElementVNode("h2",pt,t.toDisplayString(r.name),1),t.createElementVNode("ul",_t,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.definitions,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",kt,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[t.createElementVNode("span",null,t.toDisplayString(c.gloss),1),gt,t.createElementVNode("small",ft,t.toDisplayString(c.example),1)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Et=h(dt,[["render",yt]]);const Bt={props:{data:{type:Object,default:null}},data(){return{name:"Translations"}},methods:{translate(e){this.$emit("translate",e)}}},Nt={key:0},ut={class:"card-body"},wt={class:"card-title"},Vt={class:"list-group list-group-flush"},$t={class:"capitalize font-bold"},St=["onClick"],xt={class:"italic"};function Ct(e,s,l,i,r,o){return l.data.dict?(t.openBlock(),t.createElementBlock("div",Nt,[t.createElementVNode("div",ut,[t.createElementVNode("h2",wt,t.toDisplayString(r.name),1),t.createElementVNode("ul",Vt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.dict,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item"},[t.createElementVNode("h5",$t,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.word}-${_}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:f=>o.translate(c.word)},t.toDisplayString(c.word),9,St),t.createElementVNode("small",xt," \u2015 "+t.toDisplayString(c.reverse_translation.join(", ")),1)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var bt=h(Bt,[["render",Ct]]);const Tt={props:{data:{type:Object,default:null}},data(){return{name:"Examples"}}},Lt={key:0},Dt={class:"card-body"},Mt={class:"card-title font-bold"},jt={class:"list-disc"},It=["innerHTML"];function Ht(e,s,l,i,r,o){return l.data.examples?(t.openBlock(),t.createElementBlock("div",Lt,[t.createElementVNode("div",Dt,[t.createElementVNode("h2",Mt,t.toDisplayString(r.name),1),t.createElementVNode("ul",jt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.examples.example.slice(1),(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.definition_id}-${a}`,class:"mt-2 ml-2",innerHTML:n.text},null,8,It))),128))])])])):t.createCommentVNode("",!0)}var Ot=h(Tt,[["render",Ht]]);const zt={props:{data:{type:Object,default:null}},data(){return{name:"Synonyms"}}},Rt={key:0},At={class:"card-body"},Ft={class:"card-title font-bold"},Pt={class:"list-group list-group-flush"},Ut={class:"capitalize font-bold"},Gt=["onClick"],Xt=t.createElementVNode("span",null,null,-1);function Jt(e,s,l,i,r,o){return l.data.synsets?(t.openBlock(),t.createElementBlock("div",Rt,[t.createElementVNode("div",At,[t.createElementVNode("h2",Ft,t.toDisplayString(r.name),1),t.createElementVNode("ul",Pt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.synsets,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item"},[t.createElementVNode("h5",Ut,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.synonym,(f,ie)=>(t.openBlock(),t.createElementBlock("span",{key:`${f}-${ie}`},[t.createElementVNode("span",{class:"badge bg-neutral ml-1",onClick:Ne=>e.$emit("translate",f)},t.toDisplayString(f),9,Gt),Xt]))),128))]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Yt=h(zt,[["render",Jt]]);const qt={props:{data:{type:Object,default:null}},data(){return{name:"See also"}}},Kt={key:0},Qt={class:"card-body"},Wt={class:"card-title font-bold"},Zt={class:"card-body"},vt=["onClick"],te=t.createElementVNode("span",null,null,-1);function ee(e,s,l,i,r,o){return l.data.related_words&&l.data.related_words.word?(t.openBlock(),t.createElementBlock("div",Kt,[t.createElementVNode("div",Qt,[t.createElementVNode("h2",Wt,t.toDisplayString(r.name),1),t.createElementVNode("div",Zt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.related_words.word,(n,a)=>(t.openBlock(),t.createElementBlock("span",{key:`${n}-${a}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:c=>e.$emit("translate",n)},t.toDisplayString(n),9,vt),te]))),128))])])])):t.createCommentVNode("",!0)}var se=h(qt,[["render",ee]]);const ne={class:"p-1"},le={class:"mt-3 grid grid-cols-1 md:grid-cols-2"},re={class:"w-full pr-1"},oe={class:"w-full pl-1"},ae=Object.assign({name:"Popup",props:{export_data:{type:Object,default:null},export_select:{type:Object,default:null},export_tts:{type:Object,default:null}},data(){return{data:null,select:null,tts:null,replace:""}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{export_data(e){this.data=e,e.text&&this.replace!=e.text&&(this.replace=e.text)},export_select(e){this.select=e},export_tts(e){this.tts=e}},methods:{clear(){this.data=null,this.$emit("clear")},translateReplace(e){return this.translate(e,!0)},translateSwap(e){return this.translate(e,!0,!0)},translate(e,s,l){if(l){if(!this.data.src||this.data.src==="auto"||!this.data.target)return;const i=JSON.parse(JSON.stringify(this.select));i.src=this.data.target,i.target=this.data.src,this.$emit("srctarget",i)}window.scrollTo(0,0),this.clear(),s&&(this.replace=e),this.$emit("translate",e)},onSelect(e){if(this.$emit("srctarget",e),this.data){const s=this.data.sentences.map(l=>l.orig).join("");this.$emit("translate",s)}}}},{setup(e){return(s,l)=>(t.openBlock(),t.createElementBlock("div",ne,[t.createVNode(j,{select:s.select,onSelect:s.onSelect},null,8,["select","onSelect"]),t.createElementVNode("div",le,[t.createElementVNode("div",re,[t.createVNode(K,{data:s.data,tts:s.tts,replace:s.replace,onTranslate:s.translate,onClear:s.clear},null,8,["data","tts","replace","onTranslate","onClear"])]),t.createElementVNode("div",oe,[t.createVNode(ct,{data:s.data,tts:s.tts},null,8,["data","tts"])])]),s.data?(t.openBlock(),t.createElementBlock("div",{key:0,class:"mt-3 grid grid-cols-1 md:grid-cols-3 gap-3",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Et,{class:"card border",data:s.data},null,8,["data"]),t.createVNode(bt,{class:"card border",data:s.data,onTranslate:s.translateSwap},null,8,["data","onTranslate"]),t.createVNode(Yt,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"]),t.createVNode(se,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"])],4)):t.createCommentVNode("",!0),s.data?(t.openBlock(),t.createElementBlock("div",{key:1,class:"mt-5 grid grid-cols-1 gap-6",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Ot,{class:"card border",data:s.data},null,8,["data"])],4)):t.createCommentVNode("",!0)]))}});d.default=ae,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
1
+ (function(d,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(d=typeof globalThis!="undefined"?globalThis:d||self,t(d.Popup={},d.Vue))})(this,function(d,t){"use strict";var y={isRTL:N};function N(e){return["ar","fa","iw","yi","ur","pa"].indexOf(e)>-1}var h=(e,s)=>{const l=e.__vccOpts||e;for(const[i,r]of s)l[i]=r;return l};const u={props:{select:{type:Object,default:null}},emits:["select"],data(){return{src:"",target:"",recents:{src:[],target:[]}}},watch:{select(e){!e||(this.src=e.src,this.target=e.target,this.loadRecents())}},methods:{onRecentSrc(e){this.src=e,this.onSelect()},onRecentTarget(e){this.target=e,this.onSelect()},swap(){if(this.src==="auto"||!this.select.srcs[this.target]||!this.select.targets[this.src])return;const e=this.target;this.target=this.src,this.src=e,this.onSelect()},onSelect(){const e=JSON.parse(JSON.stringify(this.select));e.src=this.src,e.target=this.target,this.$emit("select",e),this.saveRecents(this.src,this.target)},loadRecents(){const e=JSON.parse(localStorage.getItem("recents"));!e||(this.recents=e)},saveRecents(e,s){this.recents.src.includes(e)||this.recents.src.push(e),this.recents.target.includes(s)||this.recents.target.push(s),this.recents.src.length>3&&this.recents.src.shift(),this.recents.target.length>3&&this.recents.target.shift(),localStorage.setItem("recents",JSON.stringify(this.recents))}}},w={key:0,class:"flex flex-row"},V=["value"],$={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},S=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"},null,-1)],b={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},x=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 7l5 5m0 0l-5 5m5-5H6"},null,-1)],C=["value"],T={key:1},L=["onClick"],M=["onClick"];function D(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock(t.Fragment,null,[l.select?(t.openBlock(),t.createElementBlock("div",w,[t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[0]||(s[0]=n=>r.src=n),class:"select select-bordered grow",onChange:s[1]||(s[1]=(...n)=>o.onSelect&&o.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.srcs,(n,a)=>(t.openBlock(),t.createElementBlock("option",{value:a,key:a},t.toDisplayString(n),9,V))),128))],544),[[t.vModelSelect,r.src]]),t.createElementVNode("button",{class:"grow-0 ml-2 mr-2",onClick:s[2]||(s[2]=(...n)=>o.swap&&o.swap(...n))},[r.src!="auto"?(t.openBlock(),t.createElementBlock("svg",$,S)):t.createCommentVNode("",!0),r.src=="auto"?(t.openBlock(),t.createElementBlock("svg",b,x)):t.createCommentVNode("",!0)]),t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[3]||(s[3]=n=>r.target=n),class:"select select-bordered grow",onChange:s[4]||(s[4]=(...n)=>o.onSelect&&o.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.targets,(n,a)=>(t.openBlock(),t.createElementBlock("option",{value:a,key:a},t.toDisplayString(n),9,C))),128))],544),[[t.vModelSelect,r.target]])])):t.createCommentVNode("",!0),l.select&&r.src&&r.target&&r.recents?(t.openBlock(),t.createElementBlock("p",T,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.src,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:a=>o.onRecentSrc(n),class:"badge badge-sm ml-1 badge-outline"},t.toDisplayString(l.select.srcs[n]),9,L))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.target,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:a=>o.onRecentTarget(n),class:"badge badge-sm ml-1 float-right mt-1"},t.toDisplayString(l.select.targets[n]),9,M))),128))])):t.createCommentVNode("",!0)],64)}var j=h(u,[["render",D]]),k={INPUT_MAX_LENGTH:5e3,INPUT_DELAY:1e3},m={init:H,autoResize:O};const g=100,E=600,I=10;function H(e,s){s&&(e.maxlength=s),e.spellcheck=!1,p(e,g)}function O(e){if(e.value==""){p(e,g);return}if(e.scrollHeight<g){p(e,g);return}if(e.scrollHeight>E){p(e,E);return}e.style.height.replace("px","")>e.scrollHeight||p(e,e.scrollHeight+I)}function p(e,s){e.style.height=`${s}px`}const B="auto_translate",z={props:{data:{type:Object,default:null},tts:{type:Object,default:null},replace:{type:String,default:""}},data(){return{input:"",INPUT_MAX_LENGTH:k.INPUT_MAX_LENGTH,input_timeout:null,player:new Audio,playing:!1,ttsIndex:0,auto_translate:!0,firstTime:!0}},computed:{rtl(){return this.data?y.isRTL(this.data.src):!1}},watch:{replace(e){this.input=e,(this.firstTime||!this.auto_translate)&&setTimeout(()=>{this.$refs.input.select()},100),this.firstTime=!1},tts(){this.ttsIndex=0},auto_translate(e){e&&this.translate(),localStorage.setItem(B,e)}},mounted(){m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.src.length){this.stop();return}this.play()}),this.$refs.input.addEventListener("input",()=>{m.autoResize(this.$refs.input),!!this.auto_translate&&(clearTimeout(this.input_timeout),this.input_timeout=setTimeout(this.translate,k.INPUT_DELAY))}),this.$refs.input.addEventListener("keyup",e=>{this.auto_translate||e&&e.keyCode===13&&this.translate()})},created(){localStorage.getItem(B)==="false"&&(this.auto_translate=!1)},methods:{play(){!this.tts.src||(this.player.src=this.tts.src[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},clear(){this.$emit("clear"),this.input="",m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.$refs.input.focus()},translate(){if(!this.input){this.clear();return}this.$emit("translate",this.input)}}},R={class:"relative indicator w-full"},A={key:0,class:"absolute top-0 left-0 w-4/5 ml-2 text-sm truncate"},F=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],P=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],U={key:2,class:"ml-1"},G={key:0},J=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)],X={class:"cursor-pointer label justify-start"},Y=t.createElementVNode("span",{class:"ml-1 label-text text-xs"},"Auto translate",-1);function q(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",R,[l.data?(t.openBlock(),t.createElementBlock("div",A,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>o.play&&o.play(...n))},F)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>o.stop&&o.stop(...n))},P)):t.createCommentVNode("",!0),l.data.ddictSrc?(t.openBlock(),t.createElementBlock("span",U,t.toDisplayString(l.data.ddictSrc),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.sentences,(n,a)=>(t.openBlock(),t.createElementBlock("span",{key:`${n.src_translit}-${a}`,class:"italic"},[n.src_translit?(t.openBlock(),t.createElementBlock("span",G," \u2015 "+t.toDisplayString(n.src_translit),1)):t.createCommentVNode("",!0)]))),128))])):t.createCommentVNode("",!0),r.input!=""?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>o.clear&&o.clear(...n)),class:"indicator-item m-3"},J)):t.createCommentVNode("",!0),t.withDirectives(t.createElementVNode("textarea",{id:"input",ref:"input","onUpdate:modelValue":s[3]||(s[3]=n=>r.input=n),class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":o.rtl?"right":"left"}),autofocus:""},null,4),[[t.vModelText,r.input,void 0,{trim:!0}]])]),t.createElementVNode("label",X,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":s[4]||(s[4]=n=>r.auto_translate=n),type:"checkbox",class:"toggle toggle-xs"},null,512),[[t.vModelCheckbox,r.auto_translate]]),Y])])}var K=h(z,[["render",q]]);const Q={props:{data:{type:Object,default:null},tts:{type:Object,default:null}},data(){return{player:new Audio,playing:!1,copied:!1,ttsIndex:0}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{data(e){if(!e){this.$refs.input.value="",m.init(this.$refs.input);return}this.$refs.input.value=e.sentences.map(s=>s.trans).join(""),m.autoResize(this.$refs.input)},tts(){this.ttsIndex=0}},mounted(){m.init(this.$refs.input),m.autoResize(this.$refs.input),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.target.length){this.stop();return}this.play()})},methods:{play(){!this.tts.target||(this.player.src=this.tts.target[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},copy(){const e=this.$refs.input.value;!e||(navigator.clipboard.writeText(e),this.copied=!0,setTimeout(()=>{this.copied=!1},500))}}},W={class:"relative indicator w-full"},Z={key:0,class:"absolute top-0 left-0 w-2/3 ml-2 text-sm truncate"},v=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],tt=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],et={key:2,class:"ml-1"},st={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},nt=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"},null,-1)],lt={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},rt=[t.createElementVNode("path",{d:"M8 2a1 1 0 000 2h2a1 1 0 100-2H8z"},null,-1),t.createElementVNode("path",{d:"M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z"},null,-1)],ot={key:0,class:"label justify-end"},at=[t.createElementVNode("span",{class:"text-xs"},"Powered by Google Translate.",-1)];function it(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",W,[l.data?(t.openBlock(),t.createElementBlock("div",Z,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>o.play&&o.play(...n))},v)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>o.stop&&o.stop(...n))},tt)):t.createCommentVNode("",!0),l.data.ddictTarget?(t.openBlock(),t.createElementBlock("span",et,t.toDisplayString(l.data.ddictTarget),1)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),l.data!=""?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>o.copy&&o.copy(...n)),class:"indicator-item m-3"},[r.copied?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("svg",st,nt)),r.copied?(t.openBlock(),t.createElementBlock("svg",lt,rt)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),t.createElementVNode("textarea",{ref:"input",class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":o.rtl?"right":"left"}),readonly:"",spellcheck:"false"},null,4)]),l.data?(t.openBlock(),t.createElementBlock("p",ot,at)):t.createCommentVNode("",!0)])}var ct=h(Q,[["render",it]]);const dt={props:{data:{type:Object,default:null}},data(){return{name:"Definitions"}}},ht={key:0},mt={class:"card-body"},pt={class:"card-title font-bold"},_t={class:"list-group list-group-flush"},kt={class:"capitalize font-bold"},gt=t.createElementVNode("br",null,null,-1),ft={class:"italic"};function yt(e,s,l,i,r,o){return l.data.definitions?(t.openBlock(),t.createElementBlock("div",ht,[t.createElementVNode("div",mt,[t.createElementVNode("h2",pt,t.toDisplayString(r.name),1),t.createElementVNode("ul",_t,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.definitions,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",kt,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[t.createElementVNode("span",null,t.toDisplayString(c.gloss),1),gt,t.createElementVNode("small",ft,t.toDisplayString(c.example),1)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Et=h(dt,[["render",yt]]);const Bt={props:{data:{type:Object,default:null}},data(){return{name:"Translations"}},methods:{translate(e){this.$emit("translate",e)}}},Nt={key:0},ut={class:"card-body"},wt={class:"card-title"},Vt={class:"list-group list-group-flush"},$t={class:"capitalize font-bold"},St=["onClick"],bt={class:"italic"};function xt(e,s,l,i,r,o){return l.data.dict?(t.openBlock(),t.createElementBlock("div",Nt,[t.createElementVNode("div",ut,[t.createElementVNode("h2",wt,t.toDisplayString(r.name),1),t.createElementVNode("ul",Vt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.dict,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",$t,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.word}-${_}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:f=>o.translate(c.word)},t.toDisplayString(c.word),9,St),t.createElementVNode("small",bt," \u2015 "+t.toDisplayString(c.reverse_translation.join(", ")),1)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Ct=h(Bt,[["render",xt]]);const Tt={props:{data:{type:Object,default:null}},data(){return{name:"Examples"}}},Lt={key:0},Mt={class:"card-body"},Dt={class:"card-title font-bold"},jt={class:"list-disc"},It=["innerHTML"];function Ht(e,s,l,i,r,o){return l.data.examples?(t.openBlock(),t.createElementBlock("div",Lt,[t.createElementVNode("div",Mt,[t.createElementVNode("h2",Dt,t.toDisplayString(r.name),1),t.createElementVNode("ul",jt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.examples.example.slice(1),(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.definition_id}-${a}`,class:"mt-2 ml-2",innerHTML:n.text},null,8,It))),128))])])])):t.createCommentVNode("",!0)}var Ot=h(Tt,[["render",Ht]]);const zt={props:{data:{type:Object,default:null}},data(){return{name:"Synonyms"}}},Rt={key:0},At={class:"card-body"},Ft={class:"card-title font-bold"},Pt={class:"list-group list-group-flush"},Ut={class:"capitalize font-bold"},Gt=["onClick"],Jt=t.createElementVNode("span",null,null,-1);function Xt(e,s,l,i,r,o){return l.data.synsets?(t.openBlock(),t.createElementBlock("div",Rt,[t.createElementVNode("div",At,[t.createElementVNode("h2",Ft,t.toDisplayString(r.name),1),t.createElementVNode("ul",Pt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.synsets,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",Ut,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.synonym,(f,ae)=>(t.openBlock(),t.createElementBlock("span",{key:`${f}-${ae}`},[t.createElementVNode("span",{class:"badge bg-neutral ml-1",onClick:Be=>e.$emit("translate",f)},t.toDisplayString(f),9,Gt),Jt]))),128))]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Yt=h(zt,[["render",Xt]]);const qt={props:{data:{type:Object,default:null}},data(){return{name:"See also"}}},Kt={key:0},Qt={class:"card-body"},Wt={class:"card-title font-bold"},Zt=["onClick"],vt=t.createElementVNode("span",null,null,-1);function te(e,s,l,i,r,o){return l.data.related_words&&l.data.related_words.word?(t.openBlock(),t.createElementBlock("div",Kt,[t.createElementVNode("div",Qt,[t.createElementVNode("h2",Wt,t.toDisplayString(r.name),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.related_words.word,(n,a)=>(t.openBlock(),t.createElementBlock("span",{key:`${n}-${a}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:c=>e.$emit("translate",n)},t.toDisplayString(n),9,Zt),vt]))),128))])])):t.createCommentVNode("",!0)}var ee=h(qt,[["render",te]]);const se={class:"p-1"},ne={class:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-3"},le={class:"w-full"},re={class:"w-full"},oe=Object.assign({name:"Popup",props:{export_data:{type:Object,default:null},export_select:{type:Object,default:null},export_tts:{type:Object,default:null}},data(){return{data:null,select:null,tts:null,replace:""}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{export_data(e){this.data=e,e.text&&this.replace!=e.text&&(this.replace=e.text)},export_select(e){this.select=e},export_tts(e){this.tts=e}},methods:{clear(){this.data=null,this.$emit("clear")},translateReplace(e){return this.translate(e,!0)},translateSwap(e){return this.translate(e,!0,!0)},translate(e,s,l){if(l){if(!this.data.src||this.data.src==="auto"||!this.data.target)return;const i=JSON.parse(JSON.stringify(this.select));i.src=this.data.target,i.target=this.data.src,this.$emit("srctarget",i)}window.scrollTo(0,0),this.clear(),s&&(this.replace=e),this.$emit("translate",e)},onSelect(e){if(this.$emit("srctarget",e),this.data){const s=this.data.sentences.map(l=>l.orig).join("");this.$emit("translate",s)}}}},{setup(e){return(s,l)=>(t.openBlock(),t.createElementBlock("div",se,[t.createVNode(j,{select:s.select,onSelect:s.onSelect},null,8,["select","onSelect"]),t.createElementVNode("div",ne,[t.createElementVNode("div",le,[t.createVNode(K,{data:s.data,tts:s.tts,replace:s.replace,onTranslate:s.translate,onClear:s.clear},null,8,["data","tts","replace","onTranslate","onClear"])]),t.createElementVNode("div",re,[t.createVNode(ct,{data:s.data,tts:s.tts},null,8,["data","tts"])])]),s.data?(t.openBlock(),t.createElementBlock("div",{key:0,class:"mt-3 grid grid-cols-1 md:grid-cols-3 gap-3",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Et,{class:"card border",data:s.data},null,8,["data"]),t.createVNode(Ct,{class:"card border",data:s.data,onTranslate:s.translateSwap},null,8,["data","onTranslate"]),t.createVNode(Yt,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"]),t.createVNode(ee,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"])],4)):t.createCommentVNode("",!0),s.data?(t.openBlock(),t.createElementBlock("div",{key:1,class:"mt-5 grid grid-cols-1 gap-6",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Ot,{class:"card border",data:s.data},null,8,["data"])],4)):t.createCommentVNode("",!0)]))}});d.default=oe,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddict/popup",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],